<template>
	<view class="tn-flex-1" style="margin: 20rpx 10rpx 0rpx 10rpx;padding: 20rpx 10rpx;" :class="isDark?'dark':''">
		<view class="tn-flex tn-flex-direction-column tn-flex-row-center tn-flex-col-center" 
			style="width: 140rpx;"  @tap="toAppInfo(item.id)">
			<view
				class="icon5__item--icon icon5__item--icon-2 tn-flex tn-flex-row-center tn-flex-col-center tn-shadow-blur"
				:style="'background-image: url(' + item.logo + ')'"
				style="background-size:100% 100%;">
			</view>
			<view class="tn-color-black tn-text-center">
				<text class="tn-text-ellipsis tn-text-ellipsis2">{{item.name}}</text>
			</view>
			<view class="tn-color-black tn-text-center tn-margin-top-sm" v-if="showDownloadBtn">
				<text class="down-button">{{$t('global.nowdownload')}}</text>
			</view>
		</view>
	</view>
</template>

<script>
	import darkModeMixin from '@/utils/darkModeMixin.js'
	export default {
		mixins: [darkModeMixin],
		props: {
			item: {
				type: Object,
				default: () => ({})
			},
			showDownloadBtn: {
				type: Boolean,
				default: true
			}
		},
		name: "appItemHorizontal",
		methods: {
			toAppInfo(id) {
				uni.navigateTo({
					url: '/pages/plugins/sy_appbox/info?id=' + id
				});
			}
		}
	}
</script>

<style lang="scss" scoped>
	@import "@/static/styles/home.scss";
	.tn-text-ellipsis2 {
		width: 140rpx; // 限制宽度与父容器一致
		white-space: nowrap;
		overflow: hidden;
		text-overflow: ellipsis;
		display: block; // 改为块级元素
	}
	.down-button {
		border-radius: 40rpx;
		background-color: #3cc9a4;
		padding: 10rpx 20rpx;
		color: white;
		font-size: 24rpx;
	}
	.icon5__item--icon-2 {
		width: 90rpx;
		height: 90rpx;
		margin-bottom: 10rpx;
	}
</style> 